Cube Yogi
Cube Yogi
Leader in Zoho Solutions/Consultation

Calculate Deal Amount based on product price and quantity in Zoho CRM

Here is our approach for calculating Deal amount based on product price and quantity in Zoho CRM

Approach

We can calculate Deal amount by creating new module as "List of products in Deal" and add it as related list into deals module while adding new product into Deals related list the total amount for all products related to the Deal is get calculated 

Note: 
 Replace right API name for fields and modules in the code before using it

1. Creating New Module

1.1 Go to Setup ---> Tap on "Modules and Fields"

1.2 Tap on "New Module"

1.3 Add necessary fields and name the module as "Products in Deals"

1.4 Add a lookup field using drag and drop

1.5 Select the module for the lookup field choose "Deals" module

1.6 Add "Quantity" field 

1.7 Drag and drop a "Formula Field"

1.8 Copy paste the code here after replacing valid module name and field name

1.9 Name the formula field as "Total Price" and save it

Code Snippet(for Formula Field)

2. Creating Workflow Rules

2.1 Go to "Setup" ---> Tap on "Workflow Rules"

2.2 Tap on "Create Rule"

2.3 Select "Products in Deals" module

2.4 Select "Create or Edit"

2.5 Choose rule to apply for entries

2.6 Select "Function" form "Instant Actions"

2.7 Tap on "Write Your Own"

2.8 Fill up mandatory fields

2.9 Copy paste the code and tap on "Edit Arguments"

2.10 Choose module Id for arguments and name the argument as "product_id"

Code Snippet

Calculating Deals Amount by finding total for all related Products with the Deal

3. Workflow rule for calculating Deal amount when Product is deleted

3.1 Follow above steps (2.1 , 2.2 and 2.3)

3.2 Select "Delete"

3.3 Follow remaining Steps (2.5 , 2.6 , 2.7 , 2.8 , 2.9 , 2.10) and Use the same code for calculating Deals Amount when a Product is deleted